<?PHP  
   include ("../../Connections/SCMS.php");
   include ("../../Model/CheckClass.php");
   include ("../../Model/errorReportClass.php");
   include ("../../Model/successReportClass.php");
   include ("../../Model/databaseOperationClass.php");
	session_start();
   $Check = new CheckClass();
   $errReport = new errorReportClass();
   $successReport = new successReportClass();
   $databaseOperation = new databaseOperationClass();
   
	$name = $_POST['username'];
	$password = $_POST['password'];

	 //Set report pass.
	$reportTo = '../view/ManufacturerViewLogin.php';
	
if ($Check->IsNull($name)) {
       $errReport->errorReport(1, $reportTo);
       exit;   
}	
if ($Check->IsNull($password)) {
       $errReport->errorReport(2, $reportTo);
       exit;   
}  

 $query = "select * from SCMS.manager where mloginname='$name' and mloginpassword='$password';";
 $sql = mysql_query($query) or die(mysql_error());
 $count = mysql_num_rows($sql);
if($Check->loginSuccess($count)){
    $_SESSION['manufacturer'] = $name;
    $SuccessPath = '../../firstpage/mainView.php';
    $successReport->linkTo($SuccessPath);
    exit;
}
else{
    $errReport->errorReport(3, $reportTo);
    exit;
}

?>
